home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / optimization tn demos / cbufffilestream / randomtestjig.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  1.6 KB  |  57 lines

  1. /*
  2.     File:        RandomTestJig.c
  3.  
  4.     Contains:    Test Jig.
  5.  
  6.     Written by:    Steve Bollinger
  7.  
  8.     Copyright:    Copyright (c) 1999 Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18. */
  19.  
  20. #include <stdio.h>
  21. #include <files.h>
  22. #include "RandomTestJig.h"
  23. #include "CreateRandExpNumbers.h"
  24.  
  25. #define NUMNUMBERS        50000
  26. #define MAXNUMVAL        1000
  27.  
  28. void TestRandom(void)
  29. {
  30.     static unsigned long        madelist1[NUMNUMBERS];
  31.     static unsigned long        madelist2[NUMNUMBERS];
  32.     static unsigned long        madelist3[NUMNUMBERS];
  33.     unsigned                    iter;
  34.     FILE                        *nufile;
  35.  
  36.     nufile = fopen("sizelist","w");
  37.  
  38.     fprintf(nufile,"%lu\n",NUMNUMBERS);
  39.  
  40.     RandomlySeedRandom();
  41.     CreateRandomExpNumbers(madelist1,MAXNUMVAL-4,NUMNUMBERS);
  42.     CreateRandomExpNumbers(madelist2,MAXNUMVAL-4,NUMNUMBERS);
  43.     CreateRandomExpNumbers(madelist3,MAXNUMVAL-4,NUMNUMBERS);
  44.  
  45.     for (iter = 0; iter < NUMNUMBERS; iter++)
  46.     {
  47.         if (madelist2[iter] < madelist1[iter])
  48.             madelist1[iter] = madelist2[iter];
  49.         if (madelist3[iter] < madelist1[iter])
  50.             madelist1[iter] = madelist3[iter];
  51.  
  52.         fprintf(nufile,"%lu\n",madelist1[iter]+4);
  53.     }
  54.  
  55.     fclose(nufile);
  56. }
  57.